package com.adcc.loadsheet.billing.security;

import org.apache.catalina.Context;
import org.apache.tomcat.util.http.LegacyCookieProcessor;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;

/**
 * Created by AN on 2020-05-19.
 */
@Component
public class EmbeddedTomcatConfig implements WebServerFactoryCustomizer {

    @Override
    public void customize(WebServerFactory webServerFactory) {
        ((TomcatServletWebServerFactory)webServerFactory).addContextCustomizers(new TomcatContextCustomizer() {
            @Override
            public void customize(Context context) {
                context.setCookieProcessor(new LegacyCookieProcessor());
            }
        });
    }
}
